import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BookingOrderEventApi } from '#/api/spa/booking/orderevent';

import { z } from '#/adapter/form';
import {
    DICT_TYPE,
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

import {DICT_SPA_TYPE} from "#/utils/dictSpa";
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'bookingOrderId',
      label: '预约订单ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预约订单ID',
      },
    },
    {
      fieldName: 'orderDetailId',
      label: '订单明细ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入订单明细ID',
      },
    },
    {
      fieldName: 'resourceRequirementId',
      label: '资源需求ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入资源需求ID',
      },
    },
    {
      fieldName: 'eventType',
      label: '事件类型',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择事件类型',
      },
    },
    {
      fieldName: 'eventStatus',
      label: '事件状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'eventTime',
      label: '事件时间',
      rules: 'required',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'eventData',
      label: '事件数据',
      component: 'Input',
      componentProps: {
        placeholder: '请输入事件数据',
      },
    },
    {
      fieldName: 'eventResult',
      label: '事件结果',
      component: 'Input',
      componentProps: {
        placeholder: '请输入事件结果',
      },
    },
    {
      fieldName: 'errorMessage',
      label: '错误信息',
      component: 'Input',
      componentProps: {
        placeholder: '请输入错误信息',
      },
    },
    {
      fieldName: 'triggerType',
      label: '触发类型',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择触发类型',
      },
    },
    {
      fieldName: 'triggerUserId',
      label: '触发用户ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入触发用户ID',
      },
    },
    {
      fieldName: 'triggerSource',
      label: '触发来源',
      component: 'Input',
      componentProps: {
        placeholder: '请输入触发来源',
      },
    },
    {
      fieldName: 'processorId',
      label: '处理人ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入处理人ID',
      },
    },
    {
      fieldName: 'processTime',
      label: '处理时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'processNotes',
      label: '处理备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入处理备注',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'bookingOrderId',
      label: '预约订单ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预约订单ID',
      },
    },
    {
      fieldName: 'orderDetailId',
      label: '订单明细ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入订单明细ID',
      },
    },
    {
      fieldName: 'resourceRequirementId',
      label: '资源需求ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入资源需求ID',
      },
    },
    {
      fieldName: 'eventType',
      label: '事件类型',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择事件类型',
      },
    },
    {
      fieldName: 'eventStatus',
      label: '事件状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择事件状态',
      },
    },
    {
      fieldName: 'eventTime',
      label: '事件时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'eventData',
      label: '事件数据',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入事件数据',
      },
    },
    {
      fieldName: 'eventResult',
      label: '事件结果',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入事件结果',
      },
    },
    {
      fieldName: 'errorMessage',
      label: '错误信息',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入错误信息',
      },
    },
    {
      fieldName: 'triggerType',
      label: '触发类型',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择触发类型',
      },
    },
    {
      fieldName: 'triggerUserId',
      label: '触发用户ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入触发用户ID',
      },
    },
    {
      fieldName: 'triggerSource',
      label: '触发来源',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入触发来源',
      },
    },
    {
      fieldName: 'processorId',
      label: '处理人ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入处理人ID',
      },
    },
    {
      fieldName: 'processTime',
      label: '处理时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'processNotes',
      label: '处理备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入处理备注',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<BookingOrderEventApi.BookingOrderEvent>['columns'] {
  return [
    {
      field: 'id',
      title: '事件ID',
      minWidth: 120,

    },
    {
      field: 'bookingOrderId',
      title: '预约订单ID',
      minWidth: 120,

    },
    {
      field: 'orderDetailId',
      title: '订单明细ID',
      minWidth: 120,

    },
    {
      field: 'resourceRequirementId',
      title: '资源需求ID',
      minWidth: 120,

    },
    {
      field: 'eventType',
      title: '事件类型',
      minWidth: 120,

    },
    {
      field: 'eventStatus',
      title: '事件状态',
      minWidth: 120,

    },
    {
      field: 'eventTime',
      title: '事件时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'eventData',
      title: '事件数据',
      minWidth: 120,

    },
    {
      field: 'eventResult',
      title: '事件结果',
      minWidth: 120,

    },
    {
      field: 'errorMessage',
      title: '错误信息',
      minWidth: 120,

    },
    {
      field: 'triggerType',
      title: '触发类型',
      minWidth: 120,

    },
    {
      field: 'triggerUserId',
      title: '触发用户ID',
      minWidth: 120,

    },
    {
      field: 'triggerSource',
      title: '触发来源',
      minWidth: 120,

    },
    {
      field: 'processorId',
      title: '处理人ID',
      minWidth: 120,

    },
    {
      field: 'processTime',
      title: '处理时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'processNotes',
      title: '处理备注',
      minWidth: 120,

    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

